package cy.security.demo.validator;

import cy.security.demo.web.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Author: ciyuan
 * @Date: 2019/5/4 22:22
 */
public class MyConstraintValidator implements ConstraintValidator<MyConstraint, Object> {

    @Autowired
    private HelloService helloService;

    @Override
    public void initialize(MyConstraint myConstraint) {
        System.out.println("my validator init");
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext context) {
        helloService.greeting("shi ciyuan ya");
        System.out.println(o);
        System.out.println(context);
        return false;
    }
}
